<template>
  <el-dialog append-to-body title="退回修改或补正" :visible="visible" @close="handleClose" width="40%">
    <el-form :model="backForm" class="white-card" label-width="100px" ref="form">
      <el-form-item label="修改内容：" prop="modifyComment">
        <el-input type="textarea" v-model="backForm.modifyComment" maxlength="300" show-word-limit></el-input>
      </el-form-item>
      <el-form-item label="补正内容：" prop="correctionComment">
        <el-input type="textarea" v-model="backForm.correctionComment" maxlength="300" show-word-limit></el-input>
      </el-form-item>
    </el-form>
    <div class="split"></div>

    <div class="dialog-footer-btn">
      <el-button @click="handleClose" type="primary" plain>关闭</el-button>
      <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import * as mixins from "@/utils/mixins";
import * as workOrderApi from "@/api/workOrder/index";
import * as templateApi from "@/api/template";

export default {
  name: "AbandonComplaint",
  mixins: [mixins.loading, mixins.form, mixins.dialog],
  props: ["visible", "details"],
  components: {},
  data() {
    return {
      backForm: {
        modifyComment: "",
        correctionComment: "",
      },
      submitting: false,
    };
  },
  computed: {},
  watch: {
    visible() {},
  },
  created() {},
  mounted() {},
  methods: {
    show() {
      /* 
        退回修改内容	1017
        退回补正内容	1018
      */
      templateApi.detailByCode(1017).then((res) => {
        this.backForm.modifyComment = res.result.value;
      });
      templateApi.detailByCode(1018).then((res) => {
        this.backForm.correctionComment = res.result.value;
      });
    },
    handleSubmit() {
      this.validateAndConfirm("form")
        .then((res) => {
          this.submitting = true;
          return workOrderApi.all.goBack({
            workOrderNo: this.details.workOrderNo,
            modifyComment: this.backForm.modifyComment,
            correctionComment: this.backForm.correctionComment,
          });
        })
        .then(() => {
          this.$emit("success");
          this.handleClose();
        })
        .finally(() => {
          this.submitting = false;
        });
    },
    /* goBack() {
      workOrderApi.all
        .goBack({
          workOrderNo: this.details.workOrderNo,
          modifyComment: this.backForm.modifyComment,
          correctionComment: this.backForm.correctionComment,
        })
        .then((r) => {
          this.playLoadData();
          this.dialogFormVisible = false;
          this.$message.success(r.msg);
        });
    }, */
  },
};
</script>
<style lang="less" scoped>
.el-select {
  width: 100%;
}
</style>
